#  Copyright (c) 2020 - ~, WANGXI
#  
#  CBR PACKET DROP ANALYSYS AWK FILE
#  Used in NS-2 simulator
#  Clone from https://gitee.com/WangXi_Chn/ns2_modulelib
#  Note in https://www.yuque.com/wangxi_chn/kozrfl
#  
#  Change Logs:
#  Date           Author       Notes			Mail
#  2020-12-09     WangXi   	   first version	WangXi_Chn@foxmail.com

BEGIN {
    # 程序初始化，设定一变量记录packet被drop的数目
    fsDrops = 0;
    numFs = 0;
}

{
    action = $1; 
    time = $2;
    node_1 = $3;
    node_2 = $4;
    type = $5;
    pktsize = $6;
    flow_id = $8;
    node_1_address = $9;
    node_2_address = $10;
    seq_no = $11;
    packet_id = $12;

    # 统计从n1送出去的包的数量
    if(node_1 = 1 && node_2 == 2 && action == "+"){
        numFs++;
    }
    # 统计flow_id 为2，且被丢掉的包的数量
    if(flow_id == 2 && action == "d"){
        fsDrops++;
    }
}

END {
    printf("number of packets sent: %d lost: %d\n",numFs,fsDrops);
}

# /************************ (C) COPYRIGHT 2020 WANGXI **************END OF FILE****/
